import { _decorator, Component, Node, tween, Vec3, Quat } from 'cc';
const { ccclass, property } = _decorator;


export default class Utils {
    /** 目标节点做呼吸缩放动画 */
    static AutoScale(target: Node) {
        tween(target)
            .to(0.5, { scale: new Vec3(0.9, 0.9, 1) })
            .to(0.5, { scale: new Vec3(1, 1, 1) })
            .union()
            .repeatForever()
            .start();
    }

    /** 目标节点做上下浮动动画 */
    static AutoUpDown(target: Node) {
        tween(target)
            .to(0.5, { position: new Vec3(target.position.x, target.position.y + 10, target.position.z) })
            .to(0.5, { position: new Vec3(target.position.x, target.position.y, target.position.z) })
            .union()
            .repeatForever()
            .start();
    }

    /** 目标节点做压扁拉伸动画 */
    static AutoSquashStretch(target: Node) {
        tween(target)
            .to(0.5, { scale: new Vec3(1.2, 0.8, 1) })
            .to(0.5, { scale: new Vec3(0.8, 1.2, 1) })
            .union()
            .repeatForever()
            .start();
    }

    /** 目标节点做旋转动画 */
    static AutoRotate(target: Node) {
        // 以Z轴旋转360度
        tween(target)
            .to(1, { angle: 30 , scale: new Vec3(0.9, 0.9, 1)})
            .to(1, { angle: 0 , scale: new Vec3(1, 1, 1)    })
            .union()
            .repeatForever()
            .start();
    }
}


